package com.hl.toolkit.server.tencent;

import com.tencent.common.Util;
import com.tencent.protocol.pay_protocol.ScanPayReqData;
import com.tencent.protocol.pay_query_protocol.ScanPayQueryReqData;
import com.util.DateUtils;

import java.util.Date;

public class Main {
	
	
	

    public static void main(String[] args) {

        try {
             //--------------------------------------------------------------------
            //温馨提示，第一次使用该SDK时请到com.tencent.common.Configure类里面进行配置
            //--------------------------------------------------------------------



            //--------------------------------------------------------------------
            //PART One:基础组件测试
            //--------------------------------------------------------------------

            //1）https请求可用性测试
            //HTTPSPostRquestWithCert.test();

            //2）测试项目用到的XStream组件，本项目利用这个组件将Java对象转换成XML数据Post给API
            //XStreamTest.test();


            //--------------------------------------------------------------------
            //PART Two:基础服务测试
            //--------------------------------------------------------------------

            //1）测试被扫支付API
           //PayServiceTest.test();
     /** ScanPayService  PayService=new ScanPayService();
        	 ScanPayReqData scanPayReqData=new ScanPayReqData("132341389318237315",
        			 "测试0.01",
        			 "1111",
        			 "TranNo" + System.currentTimeMillis()  + (long) (Math.random() * 10000000L),
        			   1,
        			   "01",
        			 "127.0.0.1",
        			 DateUtils.formatDateTime2(new Date()),
        	   		DateUtils.addMinute(5, new Date()),"",Configure.getSubMchid());
        	 String result=PayService.request(scanPayReqData);
        	 System.out.println(result); **/
 
    	
      	  String outTradeNo = "TranNo" + System.currentTimeMillis()
            + (long) (Math.random() * 1000000000000L);
     	 ScanPayReqData scanPayReqData=new ScanPayReqData("130727585841810560"
     	 		+ "","测试0.01","1111", outTradeNo,1,"01","203.110.178.139",DateUtils.formatDateTime2(new Date()),DateUtils.addMinute(5,new Date()),"");
     	 String result=WXPay.requestScanPayService(scanPayReqData);
     	 System.out.println("result:"+result);
 		 ScanPayQueryReqData scanPayQueryReqData=new ScanPayQueryReqData("",outTradeNo);
 		 try
 		{
 		     Thread.sleep(10000);
 		}
 		catch (InterruptedException e)
 		{
 		   
        	
        	
    		}
    	// String result2=WXPay.requestScanPayQueryService(scanPayQueryReqData);
    	// System.out.println("result2:"+result2);
 
        //	ReverseReqData reverseReqData=new ReverseReqData("4009972001201705120543488766","TranNo14945739290333725758");
 // 	 String result=WXScannPay.requestReverseService(reverseReqData);
        //  System.out.println(result);
        	


       	 //2）测试被扫订单查询API
 
            //3）测试撤销API
            //温馨提示，测试支付API成功扣到钱之后，可以通过调用PayQueryServiceTest.test()，将支付成功返回的transaction_id和out_trade_no数据贴进去，完成撤销工作，把钱退回来 ^_^v
            //ReverseServiceTest.test();

            //4）测试退款申请API
            //RefundServiceTest.test();

            //5）测试退款查询API
    //     RefundQueryService refundQueryService=new RefundQueryService();
     //    RefundQueryReqData refundQueryReqData=new RefundQueryReqData("","","","","");
     //  refundQueryService.request(refundQueryReqData);

            //6）测试对账单API
          //  DownloadBillServiceTest.test();
            //1）测试被扫支付API
           // PayServiceTest.test();


            //本地通过xml进行API数据模拟的时候，先按需手动修改xml各个节点的值，然后通过以下方法对这个新的xml数据进行签名得到一串合法的签名，最后把这串签名放到这个xml里面的sign字段里，这样进行模拟的时候就可以通过签名验证了
           //Util.log(Signature.getSignFromResponseString(Util.getLocalXMLString("/test/com/tencent/business/refundqueryserviceresponsedata/refundquerysuccess2.xml")));

             //Util.log(new Date().getTime());
           //  Util.log(System.currentTimeMillis());

        } catch (Exception e){
            Util.log(e.getMessage());
        }

    }

}
